<template>
  <div>
    <div class="time" v-if="isRead">
      <van-count-down :time="times*1000" @finish="finish" format="mm:ss" />
      <span>后标记为已读</span>
    </div>
    <div v-else>
      <div>已读</div>
    </div>
  </div>
</template>

<script>
import {getStorage,addStorage} from "../../utils/storage";
import {setbrowing} from "../../utils/browing";
export default {
  props: ["times", "id"],
  data() {
    return {
      isRead: true
    };
  },
  mounted() {
    let count =getStorage();
    if (count.includes(this.id * 1)) {
      this.isRead = false;
    }
  },
  methods: {
    finish() {
      addStorage(this.id * 1);
      setbrowing({bdid:this.id,time:Date.parse(new Date())})
      this.isRead = false;
      this.$toast.success("已标记为已读");
    }
  }
};
</script>

<style>
</style>